import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

export const useLoginStore = defineStore('login', () => {
  const username = ref('')
  const password = ref('')

  // 获取用户名（计算属性）
  const getUsername = computed(() => username.value)

  // 设置用户名
  function setUsername(val: string) {
    username.value = val
  }

  // 设置密码
  function setPassword(val: string) {
    password.value = val
  }

  // 清空登录信息
  function clear() {
    username.value = ''
    password.value = ''
  }


  return {
    username,
    password,
    setUsername,
    setPassword,
    clear
  }
}, {
  persist: true
})

